#
# Optional components for LDAP backend.
#

if [ X"${BACKEND}" == X"OpenLDAP" ]; then
    ${DIALOG} --backtitle "${DIALOG_BACKTITLE}" \
    --title "LDAP suffix" \
    --checklist "\
rhms provides several optional componets for LDAP backend, you can use
them by your own:
" 20 76 6 \
    "SquirrelMail" "WebMail program, written in PHP." "on" \
    "phpLDAPadmin" "Web-based LDAP browser to manage your LDAP server." "on" \
    "Mailman" "Mailing List Manager." "on" \
    "Mailgraph" "Mail statistics RRDtool frontend for Postfix." "on" \
    2>/tmp/ldap_optional_components

    LDAP_OPTIONAL_COMPONENTS="$(cat /tmp/ldap_optional_components)"

    echo ${LDAP_OPTIONAL_COMPONENTS} | grep -i squirrelmail >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_SM='YES'; echo "USE_SM='YES'" >>${CONFIG_FILE}

    echo ${LDAP_OPTIONAL_COMPONENTS} | grep -i phpldapadmin >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_PHPLDAPADMIN='YES'; echo "USE_PHPLDAPADMIN='YES'" >>${CONFIG_FILE}

    echo ${LDAP_OPTIONAL_COMPONENTS} | grep -i mailman >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_MAILMAN='YES'; echo "USE_MAILMAN='YES'" >>${CONFIG_FILE}

    echo ${LDAP_OPTIONAL_COMPONENTS} | grep -i mailgraph >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_MAILGRAPH='YES'; echo "USE_MAILGRAPH='YES'" >>${CONFIG_FILE}

    rm /tmp/ldap_optional_components

elif [ X"${BACKEND}" == X"MySQL" ]; then
    ${DIALOG} --backtitle "${DIALOG_BACKTITLE}" \
    --title "LDAP suffix" \
    --checklist "\
rhms provides several optional componets for MySQL backend, you can use
them by your own:
" 20 76 6 \
    "Roundcubemail" "WebMail program(PHP, XHTML, CSS2, AJAX)." "on" \
    "phpMyAdmin" "Web-based MySQL database management." "on" \
    "PostfixAdmin" "Web-based program to manage domains and users stored in MySQL." "on" \
    "Mailman" "Mailing List Manager." "on" \
    "Mailgraph" "Mail statistics RRDtool frontend for Postfix." "on" \
    2>/tmp/mysql_optional_components

    MYSQL_OPTIONAL_COMPONENTS="$(cat /tmp/mysql_optional_components)"

    echo ${MYSQL_OPTIONAL_COMPONENTS} | grep -i roundcubemail >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_RCD='YES'; echo "USE_RCD='YES'" >>${CONFIG_FILE}

    echo ${MYSQL_OPTIONAL_COMPONENTS} | grep -i phpmyadmin >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_PHPMYADMIN='YES'; echo "USE_PHPMYADMIN='YES'" >>${CONFIG_FILE}

    echo ${MYSQL_OPTIONAL_COMPONENTS} | grep -i postfixadmin >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_POSTFIXADMIN='YES'; echo "USE_POSTFIXADMIN='YES'" >>${CONFIG_FILE}

    echo ${MYSQL_OPTIONAL_COMPONENTS} | grep -i mailman >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_MAILMAN='YES'; echo "USE_MAILMAN='YES'" >>${CONFIG_FILE}

    echo ${MYSQL_OPTIONAL_COMPONENTS} | grep -i mailgraph >/dev/null 2>&1
    [ X"$?" == X"0" ] && USE_MAILGRAPH='YES'; echo "USE_MAILGRAPH='YES'" >>${CONFIG_FILE}

    rm /tmp/mysql_optional_components
else
    :
fi

[ X"${USE_RCD}" == X"YES" ] && . ${TOOLS_DIR}/roundcubemail_config.sh
[ X"${USE_POSTFIXADMIN}" == X"YES" ] && . ${TOOLS_DIR}/postfixadmin_config.sh
[ X"${USE_MAILMAN}" == X"YES" ] && . ${TOOLS_DIR}/mailman_config.sh
